﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using metroCIS.ViewModel;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace metroCIS.Win8Application.Views
{
    public sealed partial class Overview
    {
        OverviewViewModel _vm = new OverviewViewModel();
        public Overview()
        {
            this.InitializeComponent();

            DataContext = _vm;
            _mainGridView.ItemsSource = new[] { 
                                                    new FunctionItemViewModel("LV-Plan",         new Uri("ms-appx:/Images/overview/grinser.jpg"),  () => { Main.MainView.NavigateTo(typeof(LVPlanView)); }),
                                                    new FunctionItemViewModel("Lehrveranstaltungen",   new Uri("ms-appx:/Images/overview/kegel.jpg"), () => { Main.MainView.NavigateTo(typeof(LvInfoView)); }),
                                                    new FunctionItemViewModel("Notenübersicht",  new Uri("ms-appx:/Images/overview/now_kiss.jpg"), () => { Main.MainView.NavigateTo(typeof(GradeOverview)); }),
                                                    new FunctionItemViewModel("Freie Räume",     new Uri("ms-appx:/Images/overview/monopoly.jpg"), () => { Main.MainView.NavigateTo(typeof(GradeOverview)); }),
                                                    new FunctionItemViewModel("Mensa Menüplan",  new Uri("ms-appx:/Images/overview/mensa.jpg"),  () => { Main.MainView.NavigateTo(typeof(MensaMenu)); }),
                                              };
        }

        private void _mainGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var item = e.ClickedItem as FunctionItemViewModel;
            if(item != null)
            {
                if (item.ActionToDo != null)
                    item.ActionToDo();
            }
        }
    }
}
